#-*-coding:utf-8-*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.

class server_cpu(models.Model):
    model = models.CharField(u'型号', max_length=256, default='')
    frequency = models.CharField(u'主频', max_length=256, default='')
    thread = models.IntegerField(u'线程', default=0)
    core = models.IntegerField(u'核心', default=0)

class server_platform(models.Model):
    vendor = models.CharField(u'制造商',max_length=256, default='')
    model = models.CharField(u'型号',max_length=256, default='')
    serial = models.CharField(u'序列号', max_length=256, default='')
    arch = models.CharField(u'架构', max_length=256, default='')
    virtual = models.CharField(u'虚拟化', max_length=256, default='')
    os = models.CharField(u'操作系统', max_length=256, default='')
    kernel = models.CharField(u'内核', max_length=256, default='')

class server_layer(models.Model):
    layer_name = models.CharField(u'分层名称',max_length=256, default='')
    network = models.CharField(u'网段', max_length=256, default='')
    nginx_server = models.CharField(u'nginx服务器',max_length=256,null=True)

class server_main(models.Model):
    reportTime = models.DateTimeField(null=True)
    hostname = models.CharField(u'主机名',max_length=256, default='')
    main_ip = models.CharField(u'主IP', max_length=15, default='', unique=True)
    cpu = models.OneToOneField(server_cpu, null=True)
    memory_total_size = models.CharField(u'内存总大小', max_length=256 , default='')
    memory_free_size = models.CharField(u'内存空闲大小', max_length=256, default='')
    platform = models.OneToOneField(server_platform, null=True)
    disk_total_size = models.CharField(u'硬盘总大小', max_length=256 , default='')
    server_layer = models.ForeignKey(server_layer,null=True,on_delete=models.SET_NULL)

class server_memory(models.Model):
    size = models.CharField(u'大小',max_length=256, default='')
    type = models.CharField(u'类型',max_length=256, default='')
    speed = models.CharField(u'速度', max_length=256, default='')
    serial = models.CharField(u'序列号', max_length=256, default='')
    configSpeed = models.CharField(u'配置速度', max_length=256, default='')
    server_main = models.ForeignKey(server_main)

class server_network(models.Model):
    interface = models.CharField(u'接口', max_length=256, default='')
    speed = models.CharField(u'速度', max_length=256, default='')
    ip = models.GenericIPAddressField(u'IP',null=True)
    mac = models.CharField(u'MAC', max_length=17, default='')
    statu = models.CharField(u'状态', max_length=256, default='')
    server_main = models.ForeignKey(server_main)

class server_partition(models.Model):
    file_system= models.CharField('分区名',max_length=256)
    mount_point = models.CharField('挂载点', max_length=256)
    total_size = models.CharField(u'总大小', max_length=256, default='')
    usage_size = models.CharField(u'已使用大小', max_length=256, default='')
    server_main = models.ForeignKey(server_main)

class server_tomcat_config(models.Model):
    project_details = models.CharField(u'工程描述', max_length=256, default='')
    check_method = models.CharField(u'检测方法', max_length=256, null=True)
    check_args = models.CharField(u'检测参数', max_length=256, null=True)
    check_value = models.CharField(u'检测值', max_length=256, null=True)
    run_mode = models.CharField(u'运行方式', max_length=256)

class server_tomcat(models.Model):
    reportTime = models.DateTimeField(null=True)
    project_name = models.CharField(u'工程名', max_length=256)
    memory_config = models.CharField(u'内存配置', max_length=256, default='')
    pid = models.CharField(u'pid', max_length=256, default='')
    port = models.CharField(u'port', max_length=256, default='')
    user = models.CharField(u'系统用户', max_length=256, default='')
    group = models.CharField(u'系统组', max_length=256, default='')
    server_main = models.ForeignKey(server_main)
    server_tomcat_config = models.ForeignKey(server_tomcat_config,null=True)
